#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#define MAXN 2100333
using namespace std;

int p[MAXN][22], w[MAXN], n, q;

#define is_num(x) (x <= '9' and x >= '0')
inline int read() {
	int k = 0;
	char c = getchar();
	for(;!is_num(c); c = getchar());
	for(; is_num(c); c = getchar()) k = k * 10 + c - '0';
	return k;
} 

int find_T(int a) {
	int k = 1, x = 0;
	while(true) {
		if(k >= a) return x - 1;
		k *= 2, x++;
	}
}

int main() {
#ifdef LOCAL
	freopen("test.in", "r", stdin);
#endif
	n = read();
	memset(p, 127, sizeof(p));
	for(int  i = 1; i <= n; i++) {
		w[i] = read();
		p[i][0] = w[i]; 
	}
	
	for(int i = n; i >= 1; i--) {
		for(int j = 1; j <= 20; j++) {
			p[i][j] = min(p[i][j - 1], p[i + (1 << (j - 1))][j - 1]); 
		}
	}
	
	q = read();
	
//	for (int i = 1; i <= 10; i++) {
//		for (int j = i + 1; j <= 10; j++) {
//			int x = i, y = j;
//			int z = y - x + 1;
//			int t = find_T(z);
//			printf("%d %d : %d ~ %d and %d ~ %d\n", x, y, x, x + (1 << t) - 1, y - (1 << t) + 1, y);
//		}
//	}
	
	while(q--) {
		int x = read();
		int y = read();
		int z = y - x + 1;
		int t = find_T(z);
		if(x == y) t = 0; 
		printf("%d\n",min(p[x][t], p[y - ( 1 << t ) + 1][t]));
	}
	
	return 0;
	
}
